package com.qdu.reducer;

import com.qdu.bean.EverydayBean;
import com.qdu.bean.bikeWritable;
import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;


public class EveryDayAvgReducer extends Reducer<bikeWritable, EverydayBean, bikeWritable, EverydayBean> {


    @Override
    protected void reduce(bikeWritable key, Iterable<EverydayBean> values, Context context) throws IOException, InterruptedException {
        int casual=0;
        int registered=0;
        int count=0;
        for (EverydayBean s :
                values) {
            count+=s.getCount();
            casual+=s.getCasual();
            registered+=s.getRegistered();

            ;
        }

        context.write(key,new EverydayBean(count,casual,registered));
    }
}
